﻿using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpencvProjectBase.EmguHelper
{
    public class BitmapAndMat
    {
        public static Mat Bitmap2Mat(Bitmap bitmap)
        {
            Mat retVal = new Mat();
            Image<Bgr,byte> image = new Image<Bgr, byte>(bitmap.Width, bitmap.Height);
            image=BitmapExtension.ToImage<Bgr,byte>(bitmap);
            retVal = image.Mat;

            return retVal;
        }

        public static Bitmap Mat2Bitmap(Mat src)
        {
            Bitmap retVal = null;
            retVal=BitmapExtension.ToBitmap(src);
            return retVal;
        }
    }
}
